added SSCLI 1.0
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2010 / VBRunProcessAsUser / Kerr.Credentials / AutoGdiObject.h
blob4a9ad2f6bd55b0ba6eae9f7c7c041cc52452d497
1 //*****************************************************************************
2 //
3 // Author: Kenny Kerr
4 // Date created: 31 July 2005
5 //
6 // Description: The AutoGdiObject template class takes care of
7 // automatically deleting GDI objects such as pens, brushes
8 // and bitmaps.
9 //
10 //*****************************************************************************
12 #pragma once
14 namespace Kerr
16 template <typename T>
17 class AutoGdiObject
19 public:
21 AutoGdiObject() :
22 m_handle(0)
24 // Do nothing
27 ~AutoGdiObject()
29 if (0 != m_handle)
31 BOOL result = ::DeleteObject(m_handle);
32 Debug::Assert(0 != result);
36 T m_handle;
38 private:
40 AutoGdiObject(const AutoGdiObject&);
41 AutoGdiObject& operator=(const AutoGdiObject&);